package main

import (
	"log"
	"net/http"
	"encoding/json"
	"os"
)

func main() {

	//生成client 参数为默认
	client := &http.Client{}
	uri := "http://uniring-api-test.zring.sz/order/platform/listPage"
	request, err := http.NewRequest("GET", uri, nil)
	if err != nil {
		log.Println("http.NewRequest ERROR:", err)
		return
	}
	request.Header.Add("access_token", "YWRtaW46ZjE5NjFlNzEtYTM4My00M2M2LWFjYWMtZjdkYmZlOTM3ZTc3")

	//处理返回结果
	response, err := client.Do(request)

	if err != nil {
		log.Println("client.Do ERROR:", err)
		return
	}


	defer response.Body.Close()


	var gr gResult

	err = json.NewDecoder(response.Body).Decode(&gr)

	if err != nil {
		log.Println("json.NewDecoder Error: ", err)
		return
	}

	log.Println(gr)


	json.NewEncoder(os.Stdout).Encode(&gr)

}

type gResult struct {
	Status uint32
	Msg string `json:"msg"`
	Success bool `json:"success"`
	Data gData `json:"data"`
}

type gPage struct {
	CurrPage uint64 `json:"xxxurrPage"`
	PageSize uint8 `json:"pageSize"`
	TotalCount uint64 `json:"totalCount"`
}

type gModel struct {
	OrderNumber string `json:"orderNumber"`
	OrderCount uint64 `json:"orderCount"`
	CreateTime string `json:"createTime"`
}

type gData struct {
	Page gPage `json:"page"`
	List []gModel `json:"list"`
}



/*


{
    "status": 200,
    "msg": "OK",
    "data": {
        "page": {
            "currPage": 1,
            "pageSize": 10,
            "totalCount": 3,
            "totalPage": 1
        },
        "list": [
            {
                "orderNumber": "LSC18E310018",
                "orderCount": 1,
                "createBy": "chenghui",
                "createId": 4,
                "createTime": "2018-05-31 17:24:37",
                "storeId": 1,
                "brandName": "周大福",
                "supplierName": "供应商-周大福",
                "statusName": "待付款"
            }
        ]
    },
    "success": true
}







*/
